package com.meiqiongproperty.yiguanjia.fragment.order;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.gson.Gson;
import com.meiqiongproperty.yiguanjia.R;
import com.meiqiongproperty.yiguanjia.databinding.OrderTenementDetailLayoutBinding;
import com.meiqiongproperty.yiguanjia.fragment.BaseFragment;
import com.meiqiongproperty.yiguanjia.http.api.ApiService;
import com.meiqiongproperty.yiguanjia.http.interfaces.IHttpCallback;
import com.meiqiongproperty.yiguanjia.http.sendJsonModel.SendOrderDetailList;
import com.meiqiongproperty.yiguanjia.httpbean.order.TenementOrderDetailBean;
import com.meiqiongproperty.yiguanjia.utils.LogUtil;
import com.meiqiongproperty.yiguanjia.utils.Utils;

/**
 * author: Administrator
 * date: 2017/6/21.
 * package:com.meiqiongproperty.yiguanjia.fragment.order
 */

public class OrderTenementDetailFragment extends BaseFragment {
    OrderTenementDetailLayoutBinding binding;
    String orderId="";

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding= DataBindingUtil.inflate(inflater, R.layout.order_tenement_detail_layout,container,false);

        savedInstanceState=getArguments();
        if (savedInstanceState != null) {
            orderId = savedInstanceState.getString("orderId");
        }
        getLifeServiceDetail();
        return binding.getRoot();
    }

    /**
     * 生活服务订单详情
     */
    public void getLifeServiceDetail() {
        SendOrderDetailList send = new SendOrderDetailList();
        send.setToken(Utils.getToken(getActivity()));
        send.setRoomID(Utils.getRoomID(getActivity()));
        send.setOrderId(orderId);
        send.setOrderType("3");

        ApiService.getTenementOrderDetail(getActivity(), new IHttpCallback<TenementOrderDetailBean>() {
            @Override
            public void onNext(TenementOrderDetailBean tenementOrderDetailBean) {
                Gson gson = new Gson();
                LogUtil.d("lifeServiceOrderDetailBean===========>" + gson.toJson(tenementOrderDetailBean));
                TenementOrderDetailBean.OrderdetailBean bean=tenementOrderDetailBean.getOrderdetail();
                binding.orderTenementNumber.setText("订单号："+bean.getOrderId());
                binding.orderTenementPayStatus.setText(bean.getPayStatusName());
                binding.tenementAddress.setText("服务地址："+bean.getAddress());
                binding.tenementServicePerPrice.setText("服务单价："+bean.getUnitCost()+"元/小时");
            }

            @Override
            public void onError(int code, String message) {

            }
        }, Utils.getRequestBody(send));
    }
}
